package com.jumi.microservice.rocketmq;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import org.springframework.stereotype.Component;

@Component
public class RocketMessageListener implements MessageListener {

    @Override
    public Action consume(Message message, ConsumeContext context) {
        System.out.println("消息推送" + message);
        try {
            //do something..
            return Action.CommitMessage;
        } catch (Exception e) {
            //消费失败，挂起当前队列
            return Action.ReconsumeLater;
        }
    }
}
